//
// Created by denglibin on 2020/6/30.
//
#include "../header/graph.h"
#include <stdlib.h>
/**
 * 创建一个样例图结构，返回一个节点
 * @return
 */
GraphNode *createSimple()
{

    // 创建节点
    GraphNode *a = (GraphNode *)calloc(1, sizeof(GraphNode));
    a->value = 'a';
    a->is_visit = 0;

    GraphNode *b = (GraphNode *)calloc(1, sizeof(GraphNode));
    b->value = 'b';
    b->is_visit = 0;

    GraphNode *c = (GraphNode *)calloc(1, sizeof(GraphNode));
    c->value = 'c';
    c->is_visit = 0;

    GraphNode *d = (GraphNode *)calloc(1, sizeof(GraphNode));
    d->value = 'd';
    d->is_visit = 0;

    GraphNode *e = (GraphNode *)calloc(1, sizeof(GraphNode));
    e->value = 'e';
    e->is_visit = 0;

    GraphNode *f = (GraphNode *)calloc(1, sizeof(GraphNode));
    f->value = 'f';
    f->is_visit = 0;

    GraphNode *g = (GraphNode *)calloc(1, sizeof(GraphNode));
    g->value = 'g';
    g->is_visit = 0;

    GraphNode *h = (GraphNode *)calloc(1, sizeof(GraphNode));
    h->value = 'h';
    h->is_visit = 0;

    // 设置邻居
    GraphNode **aNeighbor = (GraphNode **)calloc(3, sizeof(GraphNode *));
    a->neighbor_num = 3;
    aNeighbor[0] = b;
    aNeighbor[1] = d;
    aNeighbor[2] = g;
    a->neighbor = aNeighbor;

    // 设置邻居
    GraphNode **bNeighbor = (GraphNode **)calloc(3, sizeof(GraphNode *));
    b->neighbor_num = 3;
    bNeighbor[0] = a;
    bNeighbor[1] = e;
    bNeighbor[2] = f;
    b->neighbor = bNeighbor;

    // 设置邻居
    GraphNode **cNeighbor = (GraphNode **)calloc(2, sizeof(GraphNode *));
    c->neighbor_num = 2;
    cNeighbor[0] = f;
    cNeighbor[1] = h;
    c->neighbor = cNeighbor;

    // 设置邻居
    GraphNode **dNeighbor = (GraphNode **)calloc(2, sizeof(GraphNode *));
    d->neighbor_num = 2;
    dNeighbor[0] = a;
    dNeighbor[1] = f;
    d->neighbor = dNeighbor;

    // 设置邻居
    GraphNode **eNeighbor = (GraphNode **)calloc(2, sizeof(GraphNode *));
    e->neighbor_num = 2;
    eNeighbor[0] = b;
    eNeighbor[1] = g;
    e->neighbor = eNeighbor;

    // 设置邻居
    GraphNode **fNeighbor = (GraphNode **)calloc(3, sizeof(GraphNode *));
    f->neighbor_num = 3;
    fNeighbor[0] = b;
    fNeighbor[1] = c;
    fNeighbor[2] = d;
    f->neighbor = fNeighbor;

    // 设置邻居
    GraphNode **gNeighbor = (GraphNode **)calloc(2, sizeof(GraphNode *));
    g->neighbor_num = 2;
    gNeighbor[0] = a;
    gNeighbor[1] = e;
    g->neighbor = gNeighbor;

    // 设置邻居
    GraphNode **hNeighbor = (GraphNode **)calloc(1, sizeof(GraphNode *));
    h->neighbor_num = 1;
    hNeighbor[0] = c;
    h->neighbor = hNeighbor;

    return a;
}
